import { Component, OnInit } from '@angular/core';
import { HttpService } from '../../../services/http.service';
import { Router,ActivatedRoute  } from "@angular/router";
import { BaseUiService } from '../../../services/base-ui.service';

@Component({
  selector: 'app-order',
  templateUrl: './order.page.html',
  styleUrls: ['./order.page.scss'],
})
export class OrderPage implements OnInit {
  constructor(
    public HttpService: HttpService,
    public router: Router,
    public activateRoute: ActivatedRoute,
    public baseUiService:BaseUiService,
  ) { }
    public orderId:any
    public applyuser:any
    public order:any = {
      fee:''
    }
    public notaryItems:any
    public materials:any
    public isleixing:any
    public isShowimg:boolean = false
    public orderImglist:any = ''
    public orderTime:any //订单的时间线
    public orderSupplements=[];
  ngOnInit() {
    this.activateRoute.queryParams.subscribe(queryParam => {
      this.orderId = queryParam.orderId;
      this.isleixing = queryParam.isleixing
    }),
    console.log('+++',this.orderId)
    this.seach()
  }
  seach(){
    let p = {
      unitGuid:this.orderId
    }
    this.HttpService.getNotaryorderById(p).then(res =>{
      if(res['code']==200){
        let {applyuser, order, notaryItems,materials,orderSupplements} = res['item']
        applyuser.forEach(e => {
          if(e.gender == 1){
            e.gender = '男'
          }else{
            e.gender = '女'
          }
          e.birthday = e.birthday.slice(0, 10)
        });
        this.applyuser = applyuser
        this.order = order
        this.notaryItems = notaryItems
        this.orderSupplements = orderSupplements;
        if(materials){
          materials.forEach(e => {
            e.annexs.forEach(i =>{
              i.filePath =  this.HttpService.upImgurl() + i.filePath
            })
          });
        }
        
        this.materials = materials
        console.log(this.materials,'123++++++')
      }else{
        alert(res['msg'])
      }
    }).catch(err =>{
      alert(err)
    })
    this.HttpService.getNotaryorderTime(p).then(res =>{
      
      if(res['code']==200){
        res['item'].forEach(e => {
          e.createDate = e.createDate.split(' ')
        });
        this.orderTime = res['item']
        console.log(this.orderTime,'++++++++++++++++++++++')
      }
    })
  }
  //撤销
  // repealOn(){
  //   let confirm = ()=>{
  //     let p = {
  //       unitGuid: this.orderId,
  //       notaryState:90
  //     }
  //     console.log(p,'+++++++')
  //     this.HttpService.repealOrder(p).then(res =>{
  //       if(res['code']==200){
  //         this.router.navigate(['/inquire'])
  //       }else{
  //         alert(res['msg'])
  //       }
  //     }).catch(err=>{
  //         alert(err)
  //     })
  //   }
  //   let cancel = ()=>{
  //     console.log("取消了")
  //   }
  //   this.baseUiService.presentAlert("撤销","","你的操作将无法取消",confirm, cancel)
  // }
  //预览
  imgClick(urlinfo:any){
    this.isShowimg = true
    this.orderImglist = ''
    this.orderImglist = urlinfo
  }
  //关闭
  iconclick(){
    this.isShowimg = false 
  }
}
